package no.ffi.gismoidm.utils;

import no.ffi.tpm.crypto.CryptoOperations;
import no.ffi.tpm.crypto.EncryptedObject;

/**
 * This class is a container for encrypted identity statements
 * @author anders
 */
public class EncryptedIdentityStatement implements java.io.Serializable {
    EncryptedObject blob;    
    public EncryptedIdentityStatement(IdentityStatement is, CryptoOperations co ) {
        try {
            blob = co.encrypt(is, is.getSubjectPublicKey());
        } catch (Exception e) { e.printStackTrace(); }
        
    }
    
    public IdentityStatement decrypt(CryptoOperations co) {
        try {
            return (IdentityStatement)
                    CryptoOperations.deserialize(co.decrypt(blob));
        } catch (Exception e) { e.printStackTrace(); }
        return null;
    }
}
